package com.wuba.rxjavademo.lyz.day0519;

import com.wuba.rxjavademo.lyz.BaseDemo;

import rx.Observable;
import rx.Subscriber;
import rx.functions.Func1;

/**
 * Created by liyaxing on 2016/5/23.
 */
public class Demo05 extends BaseDemo{

    public static void main(String[] ss){
        Observable.just(1,2,3,11,11,5,6,7,8)
                .single(new Func1<Integer, Boolean>() {
                    @Override
                    public Boolean call(Integer integer) {
                        //取大于10的第一个数字
                        return integer>10;
                    }
                })
                .subscribe(new Subscriber<Integer>() {
                    @Override
                    public void onNext(Integer item) {
                        System.out.println("Next: " + item);
                    }

                    @Override
                    public void onError(Throwable error) {
                        System.err.println("Error: " + error.getMessage());
                    }

                    @Override
                    public void onCompleted() {
                        System.out.println("Sequence complete.");
                    }
                });
       /* Observable.empty().toList().filter(new Func1<List<Object>, Boolean>() {
            @Override
            public Boolean call(List<Object> objects) {
                return objects != null && objects.size() > 0;
            }
        }).subscribe(list->{
            print(list);
        }) ;*/
    }
}
